#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
void sigint_handler(int sig){
    if(sig==SIGINT){
        printf("收到SIGINT信号%d\n",sig);
        exit(EXIT_FAILURE);

    }else if(sig==SIGTERM){
        printf("收到SIGTERM信号%d\n",sig);
        exit(EXIT_FAILURE);
    }
}
int main(int argc, char const *argv[])
{
    if(signal(SIGINT,sigint_handler)==SIG_ERR){
        perror("注册signalSIGINT失败");
        return -1;
    }

    if(signal(SIGTERM,sigint_handler)==SIG_ERR){
        perror("注册signalSIGINT失败");
        return -1;
    }

    while (1)
    {
        printf("hello world\n");
        sleep(1);
    }
    
    return 0;
}
